<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
           .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">销售物料使用申请</h2>
    </div>
    <!-- 标题 -->
    <div>
    <form action="" class="form-inline">
      <table class="row-margin-top tab-content table-bordered table" border="1">
          <tr>
            <td style="min-width: 140px;width: 140px"><label for="" class="form-label">省份<span class="colorRed">*</span>：</label></td>
            <td colspan="3"><input type="text" class="form-control" id="province" name="province" placeholder="请输入关键字或空格"><a href="javascript:;">选择</a>&nbsp;<a href="javascript:;">清空</a></td>
          </tr>
           <tr>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label">您选择的省份是：</label></td>
            <td id="provinceText">11</td>
          </tr>
              <tr>
            <td style="min-width: 140px;width: 140px"><label for="" class="form-label">品类<span class="colorRed">*</span>：</label></td>
            <td colspan="3"><input type="text" class="form-control" name="proKind" placeholder="请输入关键字或空格"><a href="javascript:;">选择</a>&nbsp;<a href="javascript:;">清空</a></td>
          </tr>
           <tr>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label">您选择的品类是：</label></td>
            <td colspan="3" id="proKindText">22</td>
          </tr>
          <tr>
			 <td style="min-width: 120px;width: 120px"><label for="" class="form-label">期望到货日期<span class="colorRed">*</span>：</label></td>
            <td> <input id="hopeDate" class="laydate-icon form-control layer-date" name="hopeDate"></td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label">使用目的<span class="colorRed">*</span>：</label></td>
            <td><input type="text" class="form-control" name="takeMb" id="takeMb"></td>
          </tr>
      </table>
     <table class="table row-margin-top table-bordered bud_hei ad_table">
      <tr class="info">
        <th class="text-center">物料名称<span class="colorRed">*</span></th>
        <th class="text-center">物料编号</th>
        <th class="text-center">费用科目<span class="colorRed">*</span></th>
        <th class="text-center">单位</th>
        <th class="text-center">单价(元)</th>
        <th class="text-center">数量<span class="colorRed">*</span></th>
        <th class="text-center">总金额(元)</th>
        <th class="text-center">体积(立方米)</th>
        <th class="text-center">重量(KG)</th>
        <th><button class="btn btn-info addTr" type="button">添加</button></th>
      </tr>
      <tr>
		<td><input type="text" name="wlName" class="form-control" placeholder="请输入关键字或空格" id="wlName"></td>
		<td></td>
		<td><input type="text" name="" class="form-control" placeholder="请输入关键字或空格" id="costProject"></td>
		<td></td>
		<td></td>
		<td><input type="text" name="" class="form-control" id="wlNum"></td>
		<td></td>
		<td></td>
		<td></td>
		<td><button class="btn btn-danger delTr" type="button">删除</button></td>
      </tr>
     </table>
    
        <div class="row text-center no-padding">
            <button class="btn btn-primary saveAndAdd" type="button">保存并再添加一条</button>
            <button class="btn btn-warning">保存</button>
            <button class="btn btn-info" type="button" onclick="back()">返回</button>
        </div>
</form>
    </div>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
    <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="__STATIC__/layout/js/common.js"></script>
    <script>
    // alert(1);
    	function back() {
    		history.go(-1);
    	}
       laydate({
            elem: '#hopeDate',
            event: 'focus'
        });
     $(document).ready(function(){

     	    $(".addTr").click(function(){
            var str = '<tr><td><input type="text" name="" class="form-control" placeholder="请输入关键字或空格"></td><td></td><td><input type="text" name="" class="form-control" placeholder="请输入关键字或空格"></td><td></td><td></td><td><input type="text" name="" class="form-control"></td><td></td><td></td><td></td><td><button class="btn btn-danger delTr" type="button">删除</button></td></tr>'
            $(".ad_table").append(str);
             });
             $(document).on("click",".delTr",function(){
             	var _$this=this
             	console.log(_$this)
             		swal({ 
						  title: "", 
						  text: "确定删除！", 
						  type: "warning",
						  showCancelButton: true, 
						  confirmButtonColor: "#DD6B55",
						  confirmButtonText: "确定", 
						  cancelButtonText: "取消",
						  closeOnConfirm: false, 
						  closeOnCancel: false
						},
						function(isConfirm){ 
						  if (isConfirm) { 
						  	// console.log(_$this);
						  	$(_$this).closest("tr").remove();
						    swal("删除！", "成功","success"); 
						   
						  } else { 
						    swal("取消！", "","error"); 
						  } 
					});
             })

      /*保存并添加一条验证*/
      var $saveAndAdd = $(".saveAndAdd");
      yanzheng($saveAndAdd);
      function  yanzheng(obj){
        var $provinceText = $("#provinceText");
        var $hopeDate     = $("#hopeDate");
        var $proKindText  = $("#proKindText");
        var $takeMb       = $("#takeMb");
        var $wlName       = $("#wlName");
        var $costProject  = $("#costProject")
        var $wlNum        = $("#wlNum");
        obj.click(function(){
          if($provinceText.html()==""){
            confirm("请选择省份！")
            return false;
          }
          if($proKindText.html()==""){
            confirm("请添加品类！")
            return false
          }
          if( $hopeDate.val() ==""){
            confirm("期望到货日期不能为空！")
          }else if($takeMb.val() ==""){
            confirm("使用目的不能为空！")
          }else if($wlName.val() == ""){
            confirm("物料名称不能为空！")
          }else if($costProject.val() == ""){
            confirm("费用科目不能为空！")
          }else if($wlNum.val() == ""){
            confirm("数量不能为空！")
          }else{
            return false;
          }
        })
      }

     })
    </script>
</body>

</html>
